package bTree.LeetCode;

public class 矩阵置零 {
    public void setZeroes(int[][] matrix) {
        int row = matrix.length;
        int line = matrix[0].length;
        boolean[][] visit = new boolean[row][line];
        for (int i = 0; i < row; i++) {
            for (int j = 0; j < line; j++) {
                if (!visit[i][j] && matrix[i][j] == 0) {
                    visit[i][j] = true;
                    for (int ii = 0; ii < line; ii++) {
                        if (matrix[i][ii] != 0) {
                            matrix[i][ii] = 0;
                            visit[i][ii] = true;
                        }

                    }
                    for (int jj = 0; jj < row; jj++) {
                        if (matrix[jj][j] != 0) {
                            matrix[jj][j] = 0;
                            visit[jj][j] = true;
                        }

                    }
                }
            }
        }
    }
}
